<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <script src="/static/js/app/pay/jquery.min.js"></script>
    <title>填写银行卡信息</title>
    <script src="/static/js/app/pay/util.js"></script>
    <script src="/static/js/app/pay/init.js"></script>
    <!--<script src="../rem.js"></script>-->
    <script src="/static/js/app/pay/rem-1.js"></script>
    <script src="/static/js/app/pay/common.js"></script>
    <link rel="stylesheet" href="commom.css">
    <style>
        *{margin: 0;padding: 0;}
        /*html,body{-webkit-text-size-adjust: 100%;-webkit-tap-highlight-color: rgba(0, 0, 0, 0);}*/
        li{list-style: none}
        .zfb-sum>b{width: 1.3rem;height: 100%;line-height: 1rem;color:#333;font-size: 0.28rem;float: left;font-weight: normal;text-align: center}
        .zfb-sum>input{ font-size: 0.28rem;color: #333;outline: none;border: 0;float: left;height: 90%;line-height: 0.9rem;width: 5rem; margin-top: 0.03rem;}
        .zfb-sum>span{width: 0.28rem;height: 0.28rem;float: right;color: #fff;background: #eee;font-size: 0.28rem;text-align: center;
            line-height: 0.24rem;border-radius: 50%;margin-top: 0.36rem;margin-right: 0.2rem}
        .zfb-add{cursor: pointer}
        .zfb-add>b{float: left;width: 0.4rem;height: 0.4rem;background: url("/static/img/app/pay/add.png") no-repeat;background-size: 100% 100%;
            margin: 0.3rem;}
        .zfb-add>h3{float: left;height: 100%;line-height: 1rem;color: #333;font-size: 0.24rem;font-weight: normal;margin: auto 0.34rem}
        .zfb-add>span{width: 0.14rem;height: 0.28rem;background: url("/static/img/app/pay/chouse.png") no-repeat;background-size: 100% 100%;
            float: right;margin: 0.36rem 0.3rem;}
        .zfb-add>p{float: left;font-size: 0.24rem;line-height: 1rem;height: 100%;color: #333;}
        .zfbforward .apply{width:6.9rem;height:0.9rem;color: #fff;background: #999;text-align: center;
            font-size: 0.32rem;line-height: 0.9rem;margin: 0 auto;border-radius: 0.04rem;margin-top: 1.4rem}
        .zfbforward .a-color{background: #f05c5c}
        /*选择银行弹窗*/
        .zfbforward .bankmask{margin: 0 auto;width:7.5rem;height: 100%;background: rgba(0,0,0,0.4);position: fixed;
            top: 0;left: 0}
        .banks{width: 100%;height:7.5rem;position: fixed;bottom: 0;left: 0;background: #fff}
        .banks>h1{color: #333;text-align: center;width: 100%;height:0.85rem;line-height: 0.85rem;font-size:0.32rem;}
        .banks-list{width: 100%;height: auto}
        .banks-list>li{width:6.9rem;height: 1rem;border-bottom:0.01rem solid #e5e5e5;margin: 0 auto }
        .banks-list>li>img{width: 1rem;height: 1rem;float: left;margin-right: 0.3rem}
        .banks-list>li>p{color: #333;font-size: 0.28rem;height: 100%;line-height: 1rem;float: left}
        .banks-list .bank-ok{width:0.41rem;height: 0.32rem;background: url("/static/img/app/pay/bankok.png") no-repeat;
            background-size: 100% 100%;float: right;margin-top: 0.3rem}
        .banks .apply{margin-top: 0.35rem}
        .hide{display: none}
        .flag{display: none}
        .message{position: fixed;top:20%;width: 100%;height: 1rem;text-align: center;}
        .message>span{color: #fff;text-align: center;line-height: 0.5rem;border-radius: 0.04rem;background: rgba(0,0,0,0.4);
            font-size: 0.2rem;display: inline-block;margin: 0 auto;padding:0 0.5rem;}
        /*li,.dismiss,#apply,.zfb-add,.maskapply,#apply{*/
             /*-webkit-tap-highlight-color:transparent;*/
         /*}*/
    </style>

</head>
<body>
<script src="/static/js/common/Monitor.js"></script>
<div class="zfbforward">
    <div class="zfb-top">
        <span class="return"></span>
        <h1>提现账户</h1>
    </div>
    <div class="zfb-sum">
        <b>姓名</b>
        <input class="bankinfo cardname"  type="text" placeholder="请输入姓名">
        <span class="dismiss hide">×</span>
    </div>
    <div class="zfb-sum">
        <b>卡号</b>
        <input class="bankinfo cardcard" type="text" placeholder="请输入银行卡号">
        <span class="dismiss hide">×</span>
    </div>
    <div class="zfb-add">
        <h3>银行</h3>
        <p>选择银行</p>
        <span></span>
        <i class="flag">false</i>
    </div>
    <div class="apply a-color" id="apply">完成</div>
    <div class="bankmask hide">
        <div class="banks">
            <h1>选择银行</h1>
            <ul class="banks-list">
                <li>
                    <img src="/static/img/app/pay/bankgong.png" alt="">
                    <p></p>
                    <i></i>
                </li>
                <li>
                    <img src="/static/img/app/pay/pankjian.png" alt="">
                    <p></p>
                    <i></i>
                </li>
                <li>
                    <img src="/static/img/app/pay/banktong.png" alt="">
                    <p></p>
                    <i></i>
                </li>
                <li>
                    <img src="/static/img/app/pay/bankxin.png" alt="">
                    <p></p>
                    <i></i>
                </li>
                <li>
                    <img src="/static/img/app/pay/bankzhao.png" alt="">
                    <p></p>
                    <i ></i>
                </li>
            </ul>
            <div class="apply a-color maskapply" >完成</div>
        </div>
    </div>
</div>
<div class="message hide" id="message"><span>请输入完整提现信息！</span></div>
<script>
    var capitalAccount = null;
    $(function () {
        initUser();
        refreshCapitalAccount();
        capitalAccount = userobj.capitalAccount ? JSON.parse(userobj.capitalAccount) : null;
        if(capitalAccount && capitalAccount.bankCode!=1){
            var text = "";
            switch (Number(capitalAccount.bankCode))
            {
                case 102:
                    text="工商银行";
                    break;
                case 105:
                    text="建设银行";
                    break;
                case 301:
                    text="交通银行";
                    break;
                case 302:
                    text="中信银行";
                    break;
                case 308:
                    text="招商银行";
                    break;
                default :
                    text="";
            }
            $(".zfb-add>p").html(text);
            //姓名和卡号
            $(".cardname").val(capitalAccount.accountName);
            $(".cardcard").val(capitalAccount.accountNo);
        }

        $(".bankinfo").on("input",function () {
            var name=$(this).val();
            if(name){
                $(this).siblings("span").removeClass("hide");
            }else{
                $(this).siblings("span").addClass("hide");
            }
        });
        $(".dismiss").click(function () {
            $(this).siblings(".bankinfo").val("");
            $(this).addClass("hide");
        });
    //    判断姓名和卡号以及是否选择银行
        $("#apply").click(function () {
            cardname=$(".cardname").val();
            cardcard=$(".cardcard").val();
            if(cardname==""){
                $("#message>span").html("请输入姓名！");
                $("#message").removeClass("hide");
                setTimeout(function () {
                    $("#message").addClass("hide");
                },2000);
            }else if(cardcard==""){
                $("#message>span").html("请输入卡号！");
                $("#message").removeClass("hide");
                setTimeout(function () {
                    $("#message").addClass("hide");
                },2000);
            }else if($(".flag").html()=="false"){
                $("#message>span").html("请选择银行");
                $("#message").removeClass("hide");
                setTimeout(function () {
                    $("#message").addClass("hide");
                },2000);
            }
        });
        //选择银行
        $(".zfb-add").click(function () {
            $(".bankmask").removeClass("hide");
            $.ajax({
                url:genUrl("/wallet/getBankList"),
                type: 'GET',
                contentType:"application/json",
                dataType:'json',
                async:false,
                headers:{
                    "x-access-id": userobj.accessId,
                    "x-access-token": userobj.accessToken,
                    "x-ua": ua
                },
                success: function (res) {
                    if(res.code==0){
                        var list=res.data.list;
                        var str="";
                        for(var i=1;i<list.length;i++){
                            bankCode=list[i].bankCode;
                            bankName=list[i].bankName;
                            $(".banks-list>li>p").eq(i-1).html(bankName);
                            $(".banks-list>li").eq(i-1).attr("data-bankcode",bankCode);
                        }
                        $(".banks-list").find("li").click(function () {
                            $(this).children("i").addClass("bank-ok");
                            $(this).siblings("li").children("i").removeClass("bank-ok");
                            bankCode=$(this).attr("data-bankcode");
                            bankName=$(this).children("p").html();
                            $(".maskapply").click(function () {
                                $(".bankmask").addClass("hide");
                                $(".zfb-add>p").html(bankName);
                                $(".flag").html("true");
                                // 修改银行卡提现账户
                                $("#apply").click(function () {
                                    if(cardname && cardcard){
                                        //调用设置资金账户
                                        $.ajax({
                                            url:genUrl("/wallet/setCapitalAccount"),
                                            type: 'GET',
                                            contentType:"application/json",
                                            dataType:'json',
                                            async:false,
                                            headers:{
                                                "x-access-id": userobj.accessId,
                                                "x-access-token": userobj.accessToken,
                                                "x-ua": ua
                                            },
                                            data:{
                                                "bankCode":bankCode,
                                                "accountName":cardname,
                                                "accountNo":cardcard
                                            },
                                            success: function (res) {
                                                console.log(res);
                                                if(res.code==0){
                                                    refreshCapitalAccount();
                                                    // window.location.href=base_url+"/putForward/cardforward.html?x-access-id="
                                                    //     +accessId+"&x-access-token="+accessToken+"&bankCode="+bankCode+"";
                                                    window.location.href=base_url+"/putForward/cardforward.html";
                                                }else{
                                                    console.log(res.message);
                                                    $("#message>span").html(res.message);
                                                    $("#message").removeClass("hide");
                                                    setTimeout(function () {
                                                        $("#message").addClass("hide");
                                                    },2000);
                                                }
                                            }
                                        });
                                    }else{

                                    }
                                });
                            });
                        });
                    }
                }
            });
        });

        // // 信息提醒(姓名)
        // $(".cardname").blur(function () {
        //     var text=$(this).val();
        //     var reg=/^[\u4e00-\u9fa5]+$/gi;
        //     if(!reg.test(text)){
        //         $("#message>span").html("您输入的姓名可能不正确，请检查");
        //         $("#message").removeClass("hide");
        //         setTimeout(function () {
        //             $("#message").addClass("hide");
        //         },2000);
        //     }
        // })
        // // 信息提醒(账号)
        // $(".cardcard").blur(function () {
        //     var text=$(this).val();
        //     var reg = /^\d+$/;
        //     if(!reg.test(text)){
        //         $("#message>span").html("您输入的账号可能不正确，请检查");
        //         $("#message").removeClass("hide");
        //         setTimeout(function () {
        //             $("#message").addClass("hide");
        //         },2000);
        //     }
        // })
    })

</script>
</body>
</html>